package com.xiaoxin.experience.service.tree.model;

import com.xiaoxin.experience.common.Property;
import com.xiaoxin.experience.service.tree.common.JsTree;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
 * @author xiaoxin
 */
@Setter
@Getter
@ToString
public class Api
{

    private String id;

    private String name;

    private String directoryId;

    /**
     * 请求方法: GET,POST,PUT,DELETE
     */
    private String requestMethod;

    /**
     * 请求地址
     */
    private String requestUrl;

    /**
     * 请求头
     */
    private List<Property> requestHeader;

    /**
     * 请求参数,url问号后面拼接参数
     */
    private List<Property> requestParam;

    /**
     * restful路径中的请求参数
     */
    private List<Property> requestPathParam;

    /**
     * 请求体
     */
    private String requestBody;

    /**
     * 鉴权方式: None,Digest,Basic
     */
    private String requestAuth;

    /**
     * 鉴权账号
     */
    private String username;

    /**
     * 鉴权密码
     */
    private String password;

    /**
     * 运行脚本
     */
    private String script;


    public JsTree toTreeNode()
    {
        return JsTree.asLeaf("api" + id,name,this);
    }
}
